package com.orange.lockscreen.server;

import java.util.ArrayList;
import java.util.List;

class LockscreenViewList {
	private List<LockscreenViewData>	mViewDatas	= new ArrayList<LockscreenViewData>();

	LockscreenViewList() {
	}

	private static final int indexInList(int viewType,
			List<LockscreenViewData> list) {
		LockscreenViewData data = null;
		final int N = list.size();
		for (int i = 0; i < N; i++) {
			data = list.get(i);
			if (data.type == viewType) {
				return i;
			}
		}
		return -1;
	}

	void add(LockscreenViewData data) {
		List<LockscreenViewData> list = mViewDatas;
		list.add(data);
	}

	LockscreenViewData get(int viewType) {
		LockscreenViewData data = null;
		int N = mViewDatas.size();
		for (int i = 0; i < N; i++) {
			data = mViewDatas.get(i);
			if (data.type == viewType) {
				return data;
			}
		}
		return null;
	}

	LockscreenViewData getItem(int index) {
		return mViewDatas.get(index);
	}

	void remove(int viewType) {
		int index = indexInList(viewType, mViewDatas);
		if (index >= 0) {
			mViewDatas.remove(index);
			return;
		}
	}

	void removeAll() {
		mViewDatas.clear();
	}

	int size() {
		return mViewDatas.size();
	}
}
